<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios 实例化</title>
</head>
<body>
<div id="app">

</div>

<script src="../../../../js/axios.js"></script>
<script type="module">
    import {createApp, onMounted} from "../../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                let instance = axios.create(
                    {
                        baseURL: "https://www.httpbin.org",
                        timeout: 5000,
                    }
                );

                /*function getRequest() {
                    instance(
                        {
                            url:"/get",
                            params: {
                                name: "abcque",
                                age: 18,
                                gender: "M",
                            }
                        }
                    ).then(function (response) {
                        console.log(response);
                    })
                }*/

                function getRequest() {
                    instance.get("/get",{params: {
                            name: "abcque",
                            age: 18,
                            gender: "M",
                        }} ).then(function (response) {
                        console.log(response);
                    })
                }

                onMounted(()=>{
                    getRequest()
                })
                return {}
            }
        }
    )
    app.mount("#app")
</script>
</body>
</html>